package com.im.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.im.app.mapper.FlowRecordLogsMapper;
import com.im.app.model.FlowRecordLogs;
import com.im.app.service.IFlowRecordLogsService;
import com.im.app.utils.text.Convert;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * 流水信息Service业务层处理
 *
 * @author ruoyi
 * @date 2023-06-12
 */
@Service
public class FlowRecordLogsServiceImpl implements IFlowRecordLogsService
{
    @Resource
    private FlowRecordLogsMapper flowRecordLogsMapper;

    /**
     * 查询流水信息
     *
     * @param id 流水信息主键
     * @return 流水信息
     */
    @Override
    public FlowRecordLogs selectFlowRecordLogsById(Long id)
    {
        return flowRecordLogsMapper.selectFlowRecordLogsById(id);
    }

    /**
     * 查询流水信息列表
     *
     * @param flowRecordLogs 流水信息
     * @return 流水信息
     */
    @Override
    public Page<FlowRecordLogs> selectFlowRecordLogsList(FlowRecordLogs flowRecordLogs, int currPage, int pageSize)
    {
        Page<FlowRecordLogs> page = new Page<>();
        page.setCurrent(currPage);
        page.setSize(pageSize);
        QueryWrapper<FlowRecordLogs> qw = new QueryWrapper<>();
        if (flowRecordLogs.getAdminId()!=null){
            qw.eq("admin_id",flowRecordLogs.getAdminId());
        }
        if(flowRecordLogs.getName()!=null){
            qw.eq("name",flowRecordLogs.getName());
        }
        qw.orderByDesc("create_time");
        return flowRecordLogsMapper.selectPage(page,qw);
    }

    /**
     * 新增流水信息
     *
     * @param flowRecordLogs 流水信息
     * @return 结果
     */
    @Override
    public int insertFlowRecordLogs(FlowRecordLogs flowRecordLogs)
    {
        return flowRecordLogsMapper.insertFlowRecordLogs(flowRecordLogs);
    }

    @Override
    public int batchInsert(List<FlowRecordLogs> flowRecordLogs){
        return flowRecordLogsMapper.batchInsert(flowRecordLogs);
    }

}
